﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QLTV_V2.DataAccess;

namespace QLTV_V2
{
    public partial class FrmReport_MT : Form
    {
        public FrmReport_MT()
        {
            InitializeComponent();
        }
        ConnectData conn = new ConnectData();
        public string maphieuMT;
        public DataTable dtb = new DataTable();
        public int dk;
        private void FrmReport_MT_Load(object sender, EventArgs e)
        {
            if (dk == 1)//IN phiếu muonj sách
            {
                dtb = getSource_MT(maphieuMT);
                CRT_MuonSach cr = new CRT_MuonSach();
                cr.SetDataSource(dtb);
                crystalReportViewer1.ReportSource = cr;
            }
            if (dk == 2)//In thống kê mượn sách
            {
                CRT_ThongkeMT crt = new CRT_ThongkeMT();
                crt.SetDataSource(dtb);
                crystalReportViewer1.ReportSource = crt;
            }
        }
        DataTable getSource_MT(string maMT)
        {
            string sql ="select b.MaMuonTra, f.MaBanDoc,TenBanDoc,f.DiaChi,NgayMuon,NgayPhaiTra,TenNV,d.MaBanSach,TenDauSach,TinhTrang " +
                        "from NhanVien a join PhieuMuonTra b on a.MaNV=b.MaNV " +
                        "join CTMuonTra c on b.MaMuonTra=c.MaMuonTra " +
                        "join BanSach d on c.MaBanSach=d.MaBanSach " +
                        "join DauSach e on d.MaDauSach=e.MaDauSach " +
                        "join BanDoc f on b.MaBanDoc=f.MaBanDoc " +
                        "where b.MaMuonTra=N'"+maMT+"'";
            return conn.GetDataTable(sql);
        }
    }
}
